//
//  FZCommonShare.h
//  FZCommonShare
//
//  Created by gzxuzhanpeng on 11/21/14.
//  Copyright (c) 2014 FZCommon. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#define ShareScreenWidth ([UIScreen mainScreen].bounds.size.width)

typedef enum {
    FZCommonShareYiXin = 0,          //开启易信分享
    FZCommonShareWeChat = 1,         //开启微信分享
    FZCommonShareWeibo = 2,          //开启微博分享
    FZCommonShareQQ = 3,             //开启QQ分享
} FZCommonShareType;

typedef enum FZCommonShareSocialSNSType {
    FZCommonShareSocialSNSTypeNone              = -1,
    FZCommonShareSocialSNSTypeOption            = 0, //自定义操作
    FZCommonShareSocialSNSTypeYixinSession      = 1, //易信好友
    FZCommonShareSocialSNSTypeYixinTimeLine     = 2, //易信朋友圈
    FZCommonShareSocialSNSTypeWeChatSession     = 3, //微信好友
    FZCommonShareSocialSNSTypeWeChatTimeLine    = 4, //微信朋友圈
    FZCommonShareSocialSNSTypeSinaWeibo         = 5, //新浪微博
    FZCommonShareSocialSNSTypeQQ                = 6, //QQ好友
    FZCommonShareSocialSNSTypeQZone             = 7, //QQ空间
    
} FZCommonShareSocialSNSType;


typedef enum FZCommonShareResponseState {
    FZCommonShareResponseStateBegin = 0,       // 开始
    FZCommonShareResponseStateSuccess = 1,     // 成功
    FZCommonShareResponseStateFail = 2,        // 失败
    FZCommonShareResponseStateCancel = 3,      // 取消
    FZCommonShareResponseStateNotInstalled = 4 // 应用没安装
} FZCommonShareResponseState;


typedef enum FZShareType: NSUInteger {
    FZShareTypeNone = -1,
    FZShareTypeWeChatTimeLine = 0,
    FZShareTypeSinaWeibo,
    FZShareTypeWeChat,
    FZShareTypeQQ,
    FZShareTypeQZone,
    FZShareTypeGroup,
} FZShareType;

/**
 分享内容结构体
 */
@interface FZCommonShareContent : NSObject

typedef enum FZCommonShareContentType {
    FZCommonShareContentTypeText = 0,
    FZCommonShareContentTypeImage = 1,
    FZCommonShareContentTypeWebpage = 2,
} FZCommonShareContentType;

@property (nonatomic) FZCommonShareContentType dataType;
@property (nonatomic, retain) NSString *text;
@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSString *desc;
@property (nonatomic, retain) NSData *imageData;
@property (nonatomic, retain) NSData *thumbnailData;
@property (nonatomic, retain) NSString *webpageUrl;
@property (nonatomic, retain) NSString *commentStr;

@end


@interface FZCommonShare : NSObject

+ (FZCommonShare *)sharedInstance;

/**
 *  init share view before share with UI
 */
- (void)initShareView;

/**
 *  hanle open url
 *
 *  @param url
 *
 *  @return return value description
 */
+ (BOOL)handleOpenURL:(NSURL *)url;

/**
 *  set share platform appkey
 *
 *  @param appkey platform appkey
 *  @param type   platform type
 */
- (void)setAppkey:(NSString *)appkey
             type:(FZCommonShareType)type;

typedef void(^FZCommonShareCompletionHandler)(FZCommonShareResponseState responseState, NSString *errorMessage);

/**
 *  share without UI
 *
 *  @param data content data for sharing
 *  @param type share SNS type
 */
- (void)shareContent:(FZCommonShareContent *)content
                type:(FZCommonShareSocialSNSType)type
       completion:(FZCommonShareCompletionHandler)completion;

/**
 *  share with default UI
 *
 *  @param data content data for sharing
 *  @param type share SNS type
 */
- (void)shareFromViewController:(UIViewController *)vc
                        content:(FZCommonShareContent *)content
                     completion:(FZCommonShareCompletionHandler)completion;


typedef void(^FZCommonShareFullCompletionHandler)(FZCommonShareSocialSNSType socialType, FZCommonShareResponseState responseState, NSString *errorMessage);

- (void)shareFromViewController:(UIViewController *)vc
                        content:(FZCommonShareContent *)content
                 fullCompletion:(FZCommonShareFullCompletionHandler)completion;

/**
 *  check if any share channels exist
 *
 *  @return YES if any share channels exist, otherwise NO
 */
- (BOOL)shareChannelExist;

/**
 *  @author Victor Ji, 15-08-19 09:08:07
 *
 *  通过分享类型来获得应用名称
 *
 *  @param type 分享类型
 *
 *  @return 应用名称
 */
- (NSString *)getSNSNameWithType:(FZCommonShareSocialSNSType)type;

@end
